#ifndef _BLOCKBREAKER_GAME_DISTRIBUTIONLOGIC_H__
#define _BLOCKBREAKER_GAME_DISTRIBUTIONLOGIC_H__

#include <Comm/Include/Channel.h>
#include <Comm/Include/SyncQueue.h>

#include <TaskLib/Include/Task.h>

#include <Game/Include/GameEvent.h>


/// \brief class that receives a game event to order between all participants events,
/// and leave it in order in an output queue so all the events are executed in the exactly same order in each partipant's PC
class DistributionLogic
{
public:
    virtual ~DistributionLogic();

    /// \brief process a game to leave it in order between other events in remotes participants
    virtual void processGameEvent(GameEvent* game_event) = 0;
    
protected:
    /// \brief Constructor
    /// \param[in] comm_channel channel to communicate with the other participant
    /// \param[in] output_queue queue used to leave the events in order
    DistributionLogic(Channel* comm_channel, SyncQueue* output_queue);
    
    Channel* comm_channel;
    SyncQueue* output_queue;

    Task* channel_receiver_task;
    static void channel_receiver_task_function(void* user_data);

    typedef struct  
    {
        Channel* channel;
        SyncQueue* output_queue;
        Task* channel_receiver_task;
    }ChannelReceiverTaskData;
};

#endif // _BLOCKBREAKER_GAME_DISTRIBUTIONLOGIC_H__
